<template>
    <div>

          
          <el-table
      class="jlTable"
      style="width: 100%;"
      :header-cell-style="{ background: '#F2F2F2', color: '#333' }"
      :data="templateList"
    >
     <el-table-column    align="center"   type="index"  label="序号"      width="50">          </el-table-column>
      <el-table-column    align="center"  prop="taskName"      label="任务名称"      width="180">
      </el-table-column>
      <el-table-column    align="center"  prop="reportTimes"      label="总周期" width="150">    </el-table-column>
      <el-table-column    align="center"  prop="inTimes"      label="所在周期" width="100">    </el-table-column>
      <el-table-column    align="center" prop="operContent"    label="本周进度" width="120">   </el-table-column>
      <el-table-column    align="center"  prop="contentPlan"      label="下周计划" width="150">
      </el-table-column>
      <el-table-column    align="center" prop="contentWarn"    label="项目预警" width="120">   </el-table-column>
      <el-table-column    align="center" prop="operUserName"    label="填报人" width="120">   </el-table-column>
      <el-table-column    align="center" prop="operDate"    label="填报时间" width="120">   </el-table-column>
    </el-table>
    </div>
</template>
<script>
import CustOrderService from "@/api/order/CustOrderService";
import OrderService from "@/api/order/OrderService";
import { mapState, mapMutations, mapActions, mapGetters } from "vuex";
export default {
    data(){
        return {
            filterMode:"98410004",
            productName:"",
            templateList:[],
            pageSize:10,
            pageIndex:0,
            total:0,
            fileList:[],
            newCTOInfo:[]

        };
    },
    props:{
	  	ODKInfo: {
			type:[ Object,String],
			default: () => {
				return {};
			},
		},
		CTOInfo: {
			type: [Array,Object],
			default: () => {
				return [];
			},
		},
  },
  computed: {
		...mapState("user", ["user"]),
	},
  mounted(){

      this.query();
  },
  
     methods: {

       async query(){
            
            if(typeof(this.CTOInfo) == "object"){
                    this.newCTOInfo = [this.CTOInfo]
            }else{
                this.newCTOInfo = this.CTOInfo;
            }
            
            var params = {};
            params.orderItemId = this.newCTOInfo[0].orderItemId;
         

            var pageInfo = {
                pageIndex: this.pageIndex,
                pageSize: this.pageSize
            }

            var custOrderId = this.newCTOInfo[0].custOrderId;//this.CTOInfo[0].custOrderId;
            var orderItemId = this.newCTOInfo[0].orderItemId;// this.CTOInfo[0].orderItemId;
            var custId = this.newCTOInfo[0].custId;//this.CTOInfo[0].custId;
            const result = await OrderService.qryTestReportList(params);

            console.log(result);
             this.templateList = result.meta.meta;
            //  this.total = result.meta.total;


        },
         //页面改变触发事件
        pageChange(val) {
            
            this.pageIndex = val;
            this.query();

        },
        handleSizeChange(val){
            
            this.pageSize = val;
            this.query();
        },
        handleRemove(file, fileList) {
            
        },
        handlePreview(file) {
            
        },
         //删除附件
    async deleteFiles(filesData) {
      var custOrderFileId= filesData.custOrderFileId;
      var custOrderId= filesData.custOrderId;
      var orderItemId= this.orderItemId;
      var fileName= filesData.fileName;
      var filePath= filesData.filePath;
      var custId= this.newCTOInfo[0].custId;// filesData.custId
      var createUser= filesData.createUser;
      var actType= 'DEL' ;

      const delResult =await OrderService.delFile({fileName,filePath,custOrderFileId,custOrderId,orderItemId,createUser,actType,custId});
      

      this.$confirm(delResult.meta, "提示", {
        confirmButtonText: "确定",
        showCancelButton: false,
        type: "warn",
        center: true
      });

     this.query();

    } ,
      async submit(val){
      
      var file = val.file;

      let paramFormData = new FormData();

      paramFormData.append("file", file);
      paramFormData.append("custOrderId", this.newCTOInfo[0].custOrderId);
      paramFormData.append("custId", this.newCTOInfo[0].custId);
      paramFormData.append("orderItemId", this.newCTOInfo[0].orderItemId);
      paramFormData.append("actType", "ADD");
      paramFormData.append("createUser", this.newCTOInfo[0].createStaff);
      paramFormData.append("fileTypeCd", this.filterMode);
      paramFormData.append("custItemFileFlag", "2");

      
      const uploadResult =await OrderService.handelUploadFile( paramFormData );
      
      if (uploadResult.code == 1) {
          this.$confirm(uploadResult.meta, "提示", {
            confirmButtonText: "确定",
            showCancelButton: false,
            type: "warn",
            center: true
          });
      }else if(uploadResult.code == 0){
        this.$confirm("附件:"+file.name+"上传成功", "提示", {
            confirmButtonText: "确定",
            showCancelButton: false,
            type: "warn",
            center: true
          });

        }

        this.query();
        },
        submitUpload() {
            this.$refs.upload.submit();
        },


     }

}
</script>
<style lang="scss">

    .el-form--inline .el-form-item {
        display: inline-flex;
        margin-right: 0.1rem;
        vertical-align: top;
        width: 100%;
    }

</style>


